package no.idi.ntnu.owl;
import java.util.ArrayList;
import java.util.Iterator;

import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.util.iterator.Filter;

public class ICD10Ontology {
	
	private OntModel ontologyModel;
	
	public OntModel getOntologyModel() {
		return ontologyModel;
	}

	public ICD10Ontology(){
		ontologyModel = loadOntology("icd10no.owl");
	}
	
	private OntModel loadOntology(String filename)
	{
		OntModel ontologyModel = ModelFactory.createOntologyModel( 
                OntModelSpec.OWL_MEM, null );
		
		ontologyModel.read("file:"+filename);
		return ontologyModel;
	}
		
	public static void main(String[] args) {
		ICD10Ontology parse = new ICD10Ontology();
		ICD10Search search = new ICD10Search();
		
		ArrayList<RDFNode> result = search.searchByLabel(parse.getOntologyModel(),"aktin");
		for (Iterator iterator = result.iterator(); iterator.hasNext();) {
			RDFNode rdfNode = (RDFNode) iterator.next();
			System.out.println(rdfNode.toString());
		}
	}
}
